fix: Prevent early loan impairment and due-date manipulation#6557
fix: Prevent early loan impairment and due-date manipulation#6557Tapanito wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## tapanito/lending-fix-amendment #6557 +/- ##
==============================================================
Coverage 81.5% 81.5%
==============================================================
Files 999 999
Lines 74550 74557 +7
Branches 7560 7558 -2
==============================================================
+ Hits 60722 60731 +9
+ Misses 13828 13826 -2
🚀 New features to boost your workflow:
|
|
This PR has conflicts, please resolve them in order for the PR to be reviewed. |
Stop impairLoan and unimpairLoan from rewriting sfNextPaymentDueDate when the amendment is active. Previously a colluding broker could repeatedly impair and unimpair an overdue loan to keep pushing the due date forward, permanently blocking default eligibility and suppressing late-interest / late-fee accrual.
| - name: Upload coverage report | ||
| if: ${{ github.repository == 'XRPLF/rippled' && !inputs.build_only && env.COVERAGE_ENABLED == 'true' }} | ||
| uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2 | ||
| uses: codecov/codecov-action@1af58845a975a7985b0beb0cbe6fbbb71a41dbad # v5.5.3 |
There was a problem hiding this comment.
Why was this changed? I think we should open a separate PR if we want to update the version
971d16b to
810ffde
Compare
|
All conflicts have been resolved. Assigned reviewers can now start or resume their review. |
There was a problem hiding this comment.
Three logic issues flagged inline: missing precondition in computeLatePayment, a duplicate isPaymentLate call, and a post-unimpair state bug that enables immediate re-impairment under featureLendingProtocolV1_1.
Review by ReviewBot 🤖
Review by Claude Opus 4.6 · Prompt: V12
| @@ -675,11 +681,6 @@ computeLatePayment( | |||
| TenthBips16 managementFeeRate, | |||
| beast::Journal j) | |||
| { | |||
There was a problem hiding this comment.
computeLatePayment lacks its own timing guard — any future caller bypasses tecTOO_SOON enforcement. Restore the precondition check inside the function:
| // ------------------------------------------------------------- | ||
| // A late payment not flagged as late overrides all other options. | ||
| if (paymentType != LoanPaymentType::late && hasExpired(view, nextDueDateProxy)) | ||
| if (paymentType != LoanPaymentType::late && isPaymentLate(view, loan)) |
There was a problem hiding this comment.
isPaymentLate called twice on the same SLE — cache the result to avoid future TOCTOU-style divergence:
bool const isLate = isPaymentLate(view, loan);
if (paymentType != LoanPaymentType::late && isLate)
| auto const normalPaymentDueDate = | ||
| std::max(loanSle->at(sfPreviousPaymentDueDate), loanSle->at(sfStartDate)) + paymentInterval; | ||
| if (!hasExpired(view, normalPaymentDueDate)) | ||
| if (!view.rules().enabled(featureLendingProtocolV1_1)) |
There was a problem hiding this comment.
unimpairLoan under featureLendingProtocolV1_1 skips advancing sfNextPaymentDueDate, leaving the loan perpetually late and re-impairable immediately. Advance the due date after clearing the impaired flag:
Stop impairLoan and unimpairLoan from rewriting
sfNextPaymentDueDate when the amendment is active. Previously a colluding broker could repeatedly impair and unimpair an overdue loan to keep pushing the due date forward, permanently blocking default eligibility and suppressing late-interest / late-fee accrual.
spec: XRPLF/XRPL-Standards#496
High Level Overview of Change
Context of Change
API Impact
libxrplchange (any change that may affectlibxrplor dependents oflibxrpl)